﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Gmis.Web.Manage.Village
{
    public partial class NewsManage : Gmis.Web.BasePage.PageBase
    {
        public string FName = "";
        public string ColumnId = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["ColumnId"] != null)
                {
                    ColumnId = Request.QueryString["ColumnId"].ToString();
                }
                else
                {
                    ColumnId = Request["ColumnId"];
                }
                bindData();
            }
        }
        /// <summary>
        /// 数据绑定，同时需要设置数据总条数
        /// 当前页与每页条数由页面中的pagerForm回传得到
        /// </summary>
        private void bindData()
        {
            string sFilter = buildFilter();

            BLL.News bll = new BLL.News();
            List<Model.News> models = bll.GetModelList(sFilter);
            TotalCount = models.Count;
            RepeaterTr.DataSource = models.Skip((PageNum - 1) * NumPerPage).Take(NumPerPage);
            RepeaterTr.DataBind();
        }

        //生成过滤脚本
        private string buildFilter()
        {
            string sFilter = " 1=1 and sColumn ='"+ColumnId+"'";
            //
            FName = Request.Form["FName"];
            if (!string.IsNullOrEmpty(FName))
                sFilter += " And sTitle Like '%" + FName + "%' ";
            return sFilter;
        }
    }
}